home *** CD-ROM | disk | FTP | other *** search
- #include "appkit.h"
- #include "dim.h"
-
- ApplicationKit::ApplicationKit(int stp, loc minsz)
- : WindowManager(stp)
- {
- applExit = 0;
- minsize = minsz;
- }
- //////////////////////////////
- int ApplicationKit::moveTo(int number)
- {
- Kit::moveTo(number);
- WindowManager::moveTo(list[current]);
- return current;
- }
- ///////////////////////////
- int ApplicationKit::shift()
- {
- ApplicationKit::moveTo(Kit::get(stack[0]));
- return current;
- }
- ///////////////////////////
- void ApplicationKit::add(Visible* object)
- {
- Kit::add(object);
- object->set_object_number(object_number + used * step);
- }
- ///////////////////////////
- void ApplicationKit::background(Visible* object)
- {
- Kit::background(object);
- object->set_object_number(object_number);
- }
- ///////////////////////////
- Visible* ApplicationKit::remove(int number)
- {
- Visible* vis = Kit::remove(number);
- return vis;
- }
- ////////////////////
- void ApplicationKit::insert(Visible* , int)
- {
- }
- ////////////////////////
- void ApplicationKit::exe(int)
- {
- if(used == 0)
- return;
-
- mouseShowCursor();
- moveTo(1);
-
- while(1)
- {
- if(!(list[current]->active()))
- WindowManager::show_window(list[current]);
- list[current]->exe();
-
- if(global_i[0])
- {
- if(global_i[0] > 100)
- {
- int w;
- if(!(w = application(global_i[0] + global_num - 1)))
- continue; // it is application function only
- if(w == 1) // it is too, but after execution hide
- { // this object and pass control to previous
- WindowManager::hide_window();
- moveTo(list[current]->isCall());
- continue;
- }
- // else --> it is not only application, we expect next menu
- }
- if(global_i[0] == AC_REDRAW)
- {
- rect work = list[current]->bound();
- if(global_i[1] == AC_MOVE)
- work = get_dim(FIG_RECTANGLE,
- MOVE, list[0]->bound(), work,
- loc(work.width(), work.height()));
- else
- work = get_dim(FIG_RECTANGLE,
- RESIZE, list[0]->bound(), work,
- screenLocLT(minsize));
-
- WindowManager::redraw_window(work);
- continue;
- }
- if(global_i[0] == AC_RESIZE || global_i[0] == AC_MOVE)
- return;
- }
-
- if(e.what == KEYEVENT || e.what == SHIFTKEYEVENT)
- {
- switch(e.key)
- {
- case EVENT_ALT_F4:
- return;
- case EVENT_ALT_F3:
- if(global_i[0] == AC_ERASE && current > 1
- && list[current]->isRet(RET_REMOVE))
- {
- WindowManager::hide_window();
- delete remove(current);
- WindowManager::show_window(list[1]);
- moveTo(1);
- continue;
- }
- if(!isRet(RET_REMOVE)) // Ignore this command
- continue;
- return;
- case EVENT_ALT_TAB:
- return;
- case EVENT_ESC:
- if(list[current]->isRet(RET_CANCEL)
- && current != 1) // to hide
- WindowManager::hide_window();
- int r;
- if((r = current) > 1) // it is possible go to previous object
- {
- int call;
- if((call = list[current]->isCall()) == 0)
- call = 1;
- WindowManager::show_window(ApplicationKit::get(call));
- moveTo(call);
- }
- if(r == 1) // !!!
- {
- if(list[1]->isRet(RET_CANCEL)
- && (applExit == 0 || application(applExit)))
- {
- e.key = EVENT_ALT_F4; // remove from upper container
- return;
- }
- continue; // it was mistake - we want not to exit
- }
- break;
- case EVENT_F10:
- F10_shift();
- break;
- case EVENT_F6: // go to the next object
- F6_shift();
- break;
- case EVENT_F2:
- case EVENT_RETURN:
- if(list[current]->isRet(RET_OK))
- WindowManager::hide_window();
- if(list[current]->isPoint())
- {
- int wh = (list[current]->isRet(RET_TRANSFER))
- ? list[current]->isPoint()
- : list[current]->isPoint() + global_num - 1;
- if(wh <= used)
- {
- get(wh)->set_call(current);
- WindowManager::show_window(list[wh]);
- moveTo(wh);
- }
- else
- {
- get(used)->set_call(current);
- WindowManager::show_window(list[used]);
- moveTo(used);
- }
- }
- else
- {
- WindowManager::show_window(
- list[list[current]->isCall()]);
- moveTo(list[current]->isCall());
- }
-
- default: break;
- }
- }
- else
- if(e.mouse1())
- {
- if(!mouse_shift(e.where()))
- return;
- }
- }
- }
- ////////////////////
- int ApplicationKit::mouse_shift(loc pos)
- {
- if(stack[s_used]->mouse_in(pos)) // Mouse pressed in the same window.
- return 1; // Return SUCCESS.
- mouseHideCursor();
-
- for(int i = s_used; i >= 1; i--) // For visible objects.
- {
- if(!stack[i]->mouse_in(pos)) // Not in this window.
- {
- if(stack[i]->isRet(RET_MOUSE)) // Hide window if
- { // necessary.
- WindowManager::moveTo(stack[i]);
- WindowManager::hide_window();
- }
- }
- else // Pressed in this
- { // window.
- WindowManager::show_window(stack[i]); // Flow up this window.
- ApplicationKit::moveTo(get(stack[s_used])); // Assign input focus.
- mouseShowCursor();
- return 1; // Return SUCCESS.
- }
- }
- if(stack[0]->mouse_in(pos)) // If 0-th, call 1-th.
- {
- ApplicationKit::moveTo(get(stack[s_used]));
- WindowManager::show_window(stack[s_used]);
- }
- else // Outside of base
- { // window.
- mouseShowCursor();
- return 0; // Return FAIL.
- }
-
- mouseShowCursor();
- return 1;
- }
- /////////////////////////
- void ApplicationKit::F10_shift()
- {
- mouseHideCursor();
- for(int i = s_used; i > 1; i--)
- {
- if(stack[i]->isRet(RET_MOUSE))
- {
- WindowManager::moveTo(stack[i]);
- WindowManager::hide_window();
- }
- }
-
- WindowManager::show_window(list[1]);
- moveTo(1);
- mouseShowCursor();
- }
- /////////////////////
- void ApplicationKit::F6_shift()
- {
- mouseHideCursor();
- while(s_used != 1 && stack[s_used]->isRet(RET_MOUSE))
- WindowManager::hide_window();
- WindowManager::show_window(stack[1]);
- moveTo(get(stack[s_used]));
- mouseShowCursor();
- }
- /////////////////////
-